#!/usr/bin/python
# -*- coding: UTF-8 -*-

"""
@author: jiu
@contact: 643562684@qq.com
@time: 2022/3/10 14:16
"""

from Conf.setting import *
from yaml import safe_load, safe_load_all
from common.base_read_file import BASE_FILE
from Conf.setting import *


class Read_Yaml(BASE_FILE):
    def __init__(self, yaml_file: str = YAML_FILE_LIST.get("database"),
                 par: bool = False):

        super(Read_Yaml, self).__init__(yaml_file)
        self.par = False

    @property
    def data(self):
        if not self._data:
            with open(self._file, 'rb') as fp:
                if not self.par:
                    self._data = safe_load(fp)  # 不带节点
                else:
                    self._data = list(safe_load_all(fp))  # 多个节点的
            for key in self._data.keys():
                if key in CONVER_LIST:
                    self.data[key] = int[self.data[key]]
            return self._data

